package com.columboid.web.helper;

import java.util.Hashtable;
import java.util.UUID;

public class DataStorage {
	private static Hashtable<String, String> hashToken = new Hashtable<String, String>();
	
	public static String getToken(String user)
	{
		if(!hashToken.containsKey(user))
		{
			String nonce = UUID.randomUUID().toString();
			hashToken.put(user, nonce);
			return nonce;
		}
		return hashToken.get(user);
	}
	
	public static String setToken(String user)
	{
		String nonce = UUID.randomUUID().toString();
		if(!hashToken.containsKey(user))
		{
			hashToken.put(user, nonce);
		}
		else
		{
			hashToken.put(user, nonce);
		}
		return nonce;
	}
	
	public static void resetToken(String user)
	{
		if(!hashToken.containsKey(user))
		{
			hashToken.remove(user);
		}
	}
	
	public static String getPassword(String user)
	{
		

		
		return "/tO2GyYIGEk3gICzTmk9Lg=="; // MD5 of "testPassword"
	}
	
	
	public static Boolean checkClientPublicKey(String user)
	{
		if(user.length()<=5)
		{
			return true;
		}
		return false;
	}
	
	public static Boolean saveClientPublicKey(String user,String publicKey)
	{
		return true;
	}
	
	public static String getServiceAddr(String user)
	{
		return "http://www.columboid.com/Service";
	}
}
